﻿<!--#include file="db.asp"--><%
'
'	七色虎建站系统
'	数据库兼容补丁文件Update.asp
'	用于兼容旧版的数据库，适用v1.2.6 正式版的数据库
'	v1.2.7
'	2012.6.2

Server.ScriptTimeout = 999999

myconnstr="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database PASSWORD=;Data Source="&Server.MapPath(""&db&"")
set myconn=server.createobject("ADODB.CONNECTION")
myconn.open myconnstr

On Error Resume Next
myconn.Execute("select top 1 id from 74hu_bbs")
If Err.Number<>0 Then
	Err.Clear
	myconn.Execute("ALTER TABLE [74hu_article] add column [type] long default 0")
	myconn.Execute("ALTER TABLE [74hu_article] add column [subtype] long default 0")
	myconn.Execute("ALTER TABLE [74hu_article] add column [recommend] long default 0")
	myconn.Execute("ALTER TABLE [74hu_article] add column [payid] memo")
	myconn.Execute("ALTER TABLE [74hu_article] add column [fileid] long default 0")
	myconn.Execute("UPDATE [74hu_article] set [type]=0,[subtype]=0,[recommend]=0,[fileid]=0")
	myconn.Execute("Delete From [74hu_iprr]")
	myconn.Execute("ALTER TABLE [74hu_iprr] add column [time] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_iprr] add column [link] text(200)")
	myconn.Execute("ALTER TABLE [74hu_iprr] add column [userid] long default 0")
	myconn.Execute("ALTER TABLE [74hu_class] add column [hide] long default 0")
	myconn.Execute("UPDATE [74hu_class] set [hide]=0")
	myconn.Execute("UPDATE [74hu_class] set [hide]=1 where [pid]<0")
	myconn.Execute("UPDATE [74hu_class] set wmltxt=relid where lx in(10,11,12,13,14,15) and relid<>0")
	myconn.Execute("UPDATE [74hu_class] set relid=classid where lx=3")
	myconn.Execute("ALTER TABLE [74hu_user] add column [mobile] text(50)")
	myconn.Execute("ALTER TABLE [74hu_user] add column [points] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [status] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [email] text(50)")
	myconn.Execute("ALTER TABLE [74hu_user] add column [onlinetime] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [setting] text(200)")
	myconn.Execute("ALTER TABLE [74hu_user] add column [continuedays] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [face] text(50)")
	myconn.Execute("ALTER TABLE [74hu_user] add column [experience] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [vip] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [family] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [bank] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] add column [gift] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] ALTER column [hu_level] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] ALTER column [money] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] ALTER column [regtime] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_user] ALTER column [sex] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] ALTER column [topic] long default 0")
	myconn.Execute("ALTER TABLE [74hu_user] ALTER column [reply] long default 0")
	myconn.Execute("UPDATE [74hu_user] set [points]=0,[status]=0,[onlinetime]=0,[continuedays]=0,[experience]=0,[vip]=0,[family]=0,[bank]=0,[gift]=0")
	myconn.Execute("ALTER TABLE [74hu_topic] add column [subtype] long default 0")
	myconn.Execute("UPDATE [74hu_topic] set [subtype]=0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [classid] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [hit] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [userid] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [savetime] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [livetime] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [reply] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [type] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [pid] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [access] long default 0")
	myconn.Execute("ALTER TABLE [74hu_topic] ALTER column [edittype] long default 0")
	myconn.Execute("ALTER TABLE [74hu_reply] ALTER column [savetime] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_friend] add column [group] long default 0")
	myconn.Execute("ALTER TABLE [74hu_friend] ALTER column [state] long default 0")
	myconn.Execute("UPDATE [74hu_friend] set [group]=0")
	myconn.Execute("ALTER TABLE [74hu_message] ALTER column [savetime] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_message] ALTER column [state] long default 0")
	myconn.Execute("ALTER TABLE [74hu_message] ALTER column [flag] long default 0")
	myconn.Execute("ALTER TABLE [74hu_broadcast] ALTER column [type] long default 0")
	myconn.Execute("ALTER TABLE [74hu_broadcast] ALTER column [savetime] datetime default Now()")
	myconn.Execute("ALTER TABLE [74hu_zonemark] ALTER column [savetime] datetime default Now()")
	myconn.Execute("CREATE TABLE [74hu_transaction] ([id] counter primary key,[userid] long default 0,[type] long default 0,[subtype] long default 0,[savetime] datetime default now(),[remark] text(50),[action] long default 0)")
	myconn.Execute("CREATE TABLE [74hu_bbs] ([id] counter primary key,[classid] long default 0,[name] text(50),[remark] text(200),[host] long default 0,[edit] long default 0,[access] long default 0,[money] long default 0,[savetime] datetime default now(), [subtype] long default 0,[reward] text(50),[punish] text(50))")
	myconn.Execute("CREATE TABLE [74hu_passwordask] ([id] counter primary key,[question] text(50))")
	myconn.Execute("insert into [74hu_passwordask] ([question]) values ('最开心的事?')")
	myconn.Execute("insert into [74hu_passwordask] ([question]) values ('最喜欢的东西?')")
	myconn.Execute("insert into [74hu_passwordask] ([question]) values ('最喜欢的电影?')")
	myconn.Execute("insert into [74hu_passwordask] ([question]) values ('最好的朋友?')")
	myconn.Execute("insert into [74hu_passwordask] ([question]) values ('最喜欢的人?')")
	myconn.Execute("insert into [74hu_passwordask] ([question]) values ('最喜欢的歌?')")
	myconn.Execute("CREATE TABLE [74hu_password] ([id] counter primary key,[userid] long default 0,[ask1] long default 0,[ans1] text(50),[ask2] long default 0,[ans2] text(50),[ask3] long default 0,[ans3] text(50),[savetime] datetime default now())")
	myconn.Execute("CREATE TABLE [74hu_vip] ([id] counter primary key,[userid] long default 0,[start] datetime,[end] datetime,[days] long default 0)")
	myconn.Execute("CREATE TABLE [74hu_download] ([id] counter primary key,[userid] long default 0,[url] text(200),[savetime] datetime default now(),[buy] long default 0,[buyer] memo,[filesize] long default 0,[filetype] text(50))")
	myconn.Execute("CREATE TABLE [74hu_mark] ([id] counter primary key,[name] text(50),[remark] memo,[savetime] datetime default now(),[discount] long default 0,[outdate] datetime,[amount] long default 0, [money] long default 0,[points] long default 0,[experience] long default 0,[buyer] long default 0)")
	myconn.Execute("CREATE TABLE [74hu_markcomment] ([id] counter primary key,[markid] long default 0,[userid] long default 0,[amount] long default 0,[savetime] datetime default now(), [money] long default 0,[score] long default 0,[remark] text(50))")
	myconn.Execute("CREATE TABLE [74hu_friendlist] ([id] counter primary key,[userid] long default 0,[name] text(50),[sort] long default 0)")
	myconn.Execute("CREATE TABLE [74hu_family] ([id] counter primary key,[userid] long default 0,[name] text(50),[amount] long default 0,[money] long default 0,[access] long default 0,[savetime] datetime default now(),[remark] text(50),[cost] long default 0)")
	myconn.Execute("CREATE TABLE [74hu_chat] ([id] counter primary key,[type] long default 0,[subtype] long default 0,[userid] long default 0,[content] text(255),[savetime] datetime default now())")
	myconn.Execute("CREATE TABLE [74hu_prison] ([id] counter primary key,[userid] long default 0,[remark] text(50),[savetime] datetime default now(),[days] long default 0,[status] long default 0,[hunter] long default 0)")
	myconn.Execute("CREATE TABLE [74hu_bookmark] ([id] counter primary key,[userid] long default 0,[type] long default 0,[subtype] long default 0,[remark] text(50),[url] text(50))")
	Set rs=Server.CreateObject("ADODB.Recordset")
	rs.open "select classid,class,wmltxt,relid from 74hu_class where lx=3",myconn,1,3
	If Not rs.eof Then
		While Not rs.eof
			classid=rs("classid")
			relid=rs("relid")
			If relid="" Or IsNumeric(relid)=False Then relid=0
			myconn.Execute("insert into [74hu_bbs] ([classid],[name],[remark],[host]) values("&classid&",'"&rs("class")&"','"&rs("wmltxt")&"',"&relid&")")
			rs("relid")=classid
			rs.update
			rs.movenext
		Wend
	End If
	rs.close
	Set rs=Nothing
	If Err.Number<>0 Then
		response.write "Database Update: Help http://74hu.cn"
	Else
		response.write "Database Update: OK"
	End If
Else
	response.write "Database Update: No Problem"
End If

response.write "<br/>"

myconn.close
Set myconn=Nothing

connstr="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database PASSWORD=;Data Source="&Server.MapPath(""&dbm&"")
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr

Err.Clear

conn.Execute("select top 1 id from 74hu_plugin")
If Err.Number<>0 Then
	Err.Clear
	conn.Execute("CREATE TABLE [74hu_plugin] ([id] counter primary key,[name] text(50),[url] text(50),[installed] long default 0,[savetime] datetime default now(),[remark] memo)")
	If Err.Number<>0 Then
		response.write "Admin Database Update: Help http://74hu.cn"
	Else
		response.write "Admin Database Update: OK"
	End If
Else
	response.write "Admin Database Update: No Problem"
End If

conn.close
set conn=Nothing
%>